using Godot;
using System;

public partial class World : Node2D
{
    [Export]
    public TileMapLayer tileMapLayer;
    [Export]
    public Camera2D camera2D;

    public override void _Ready()
    {
        var used = tileMapLayer.GetUsedRect().Grow(-1);
        var tile_size = tileMapLayer.TileSet.TileSize;

        camera2D.LimitTop = used.Position.Y * tile_size.Y;
        camera2D.LimitBottom = used.End.Y  * tile_size.Y;
        camera2D.LimitLeft = used.Position.X * tile_size.X;
        camera2D.LimitRight = used.End.X * tile_size.X;

        camera2D.ResetSmoothing();
    }
}
